package game.utils;

import com.javaGame.util.CutImage;
import game.roles.bullets.*;
import game.roles.enemys.*;
import game.roles.gamer.BaseGamer;
import game.roles.gamer.Helicopter;
import game.roles.gifts.Gift1;
import game.roles.gamer.Gamer;
import game.roles.visual.BackgroundMaps;
import game.roles.visual.Blast;
import game.roles.visual.Boom;

import javax.swing.*;
import java.awt.*;

/**
 * @author liuyulai
 * Created with IntelliJ IDEA.
 * Date: 21.5.6
 * Time: 20:24
 * Description: 初始化角色资源
 */
public class ImageLoad {
    public static void load(JFrame jFrame) {
        //创建媒体跟踪器
        MediaTracker mt = new MediaTracker(jFrame);
        //地图图片
        BackgroundMaps.mapImg = CutImage.getSingleImage("img/background.png", mt, 1);
        //boss1普通形态
        Boss.bossImgArray = CutImage.cutOneImage("img/boss/boss1playSpear.png", 18, mt, 1);
        //boss1进攻形态
        Boss.bossAttackImg = CutImage.cutOneImage("img/boss/boss1cleave.png", 12, mt, 1);
        //boss2状态
        Boss2.boss2Images = CutImage.cutOneImage("img/boss/boss2.png", 10, mt, 1);
        //玩家无敌前进态
        Gamer.gamerArrayFront = CutImage.cutOneImage("img/player/playerFront.png", 10, mt, 1);
        //玩家前进态
        Gamer.gamerArrayFrontNormal = CutImage.cutOneImage("img/player/playerFront.png", 10, mt, 1);
        //玩家无敌后退态
        Gamer.gamerArrayBack = CutImage.cutOneImage("img/player/playerBack.png", 10, mt, 1);
        //玩家后退态
        Gamer.gamerArrayBackNormal = CutImage.cutOneImage("img/player/playerBack.png", 10, mt, 1);
        //玩家A键释放鸵鸟屁
        Gamer.gamerSpin = CutImage.cutOneImage("img/player/playerFront.png", 10, mt, 1);
        //玩家死亡态
        BaseGamer.gamerDead = CutImage.cutOneImage("img/player/playerDied.png", 9, mt, 1);
        //鸵鸟屁
        RoundBoom.flowerImage = CutImage.cutOneImage("img/playerBullet/flower.png", 8, mt, 1);
        //玩家普通子弹
        NormalBullet.bullet1 = CutImage.getSingleImage("img/playerBullet/gamerBullet.png", mt, 1);
        //玩家普通子弹
        IceBullet.bullet2 = CutImage.cutOneImage("img/playerBullet/ice.png", 3, mt, 1);
        //士兵1
        Soldier1.solider1 = CutImage.cutOneImage("img/tanks/tank.png", 8, mt, 1);
        //士兵2
        Solider2.solider2 = CutImage.cutOneImage("img/enemy/enemy2.png", 2, mt, 1);
        //士兵3
        Solider3.solider3Images = CutImage.cutOneImage("img/enemy/enemy3.png", 9, mt, 1);
        //士兵4
        Solider4.solider4 = CutImage.cutOneImage("img/enemy/enemy4.png", 10, mt, 1);
        //爆炸效果
        Boom.boomImages = CutImage.cutOneImage("img/bomb/detonate.png", 5, mt, 1);
        //击中效果
        Blast.blastImage = CutImage.cutOneImage("img/bomb/blast.png", 4, mt, 1);
        //星星子弹效果
        StarBullet.starImages = CutImage.cutOneImage("img/enemyBullet/starBullet.png", 3, mt, 1);
        //火焰子弹效果
        FireBullet.fireBullet = CutImage.cutOneImage("img/enemyBullet/fireBullet.png", 7, mt, 1);
        //玩家奖励道具
        Gift1.giftImage = CutImage.cutOneImage("img/gift/gift.png", 6, mt, 1);
        //玩家sp爆炸效果
        BigBoom.bigBooms = CutImage.cutOneImage("img/bomb/bigBoom.png", 11, mt, 1);
        //友军坦克
        FriendlyTank.friendlyTankImage = CutImage.cutOneImage("img/tanks/playerTank.png", 10, mt, 1);
        //友军直升机
        Helicopter.helicopterImages = CutImage.cutOneImage("img/player/helicopters.png", 30, mt, 1);
        //友军直升机相反
        Helicopter.helicopterImagesBack = CutImage.cutOneImage("img/player/helicoptersBack.png", 30, mt, 1);
        //掉落的坦克炸弹
        DropTank.dropTankImages = CutImage.cutOneImage("img/tanks/dropTanks.png", 9, mt, 1);
        try {
            //id为1的图片全部都加载完毕后再一起进行显示
            mt.waitForID(1);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
